#ifndef __BS_H__
#define __BS_H__

/* 比特流结构体 */
typedef struct bs_s {
    unsigned char *p_start;
    unsigned char *p;
    unsigned char *p_end;
    int i_left; /* i_count number of available bits */
} bs_t;

void bs_init(bs_t *s, unsigned char *p_data, int i_data);
unsigned int bs_read_be(bs_t *s, int i_count);
unsigned int bs_read_le(bs_t *s, int i_count);
void bs_read_bytes_le(bs_t *s, unsigned char *p_data, int n_bytes);
void bs_write_be(bs_t *s, unsigned int i_bits, int i_count);
void bs_write_le(bs_t *s, unsigned int i_bits, int i_count);
void bs_write_bytes_le(bs_t *s, unsigned char *p_data, int n_bytes);
void bs_skip(bs_t *s, int i_count);

#endif